//
//  TargetDetailViewController.swift
//  Accounting
//
//  Created by Qingke on 16/5/11.
//  Copyright © 2016年 Qingke. All rights reserved.
//

import UIKit

class TargetDetailViewController: UITableViewController {

    var dataModel: DataModel!

    var customDate: String = "date"
    var customMark: String = "mark"
    var customIcon: UIImage?
    

    
    override func viewDidLoad() {
        super.viewDidLoad()
//        let navigationController = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("navigation")  as? UINavigationController
//        let controller = navigationController?.topViewController as! AddTargetViewController
//        controller.viewDidDisappear(true)
//        controller.addTargetDelegate = self
        let controller = UIApplication.sharedApplication().delegate as! AppDelegate
        dataModel = controller.dataModel

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }

    // MARK: - Table view data source

    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return dataModel.iconCategory.count
    }

    
    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier("reuseIdentifier", forIndexPath: indexPath)

        // Configure the cell...
        let iconcategory = dataModel.iconCategory[indexPath.row]
        cell.imageView?.image = iconcategory.customIcon
        cell.textLabel?.text = "\(iconcategory.customMark)" + "花费\(iconcategory.customAddMoney)元" + "\(iconcategory.customDate)"

        return cell
    }

    @IBAction func backButtonn(sender: UIBarButtonItem) {
        dismissViewControllerAnimated(true, completion: nil)
    }

}
//extension TargetDetailViewController: AddTargetDelegate {
//    func addtargetDelegateViewController(viewcontroller: AddTargetViewController, customDate: String, custonIcon: UIImage, mark: String) {
//        self.customDate = customDate
//        self.customIcon = custonIcon
//        self.customMark = mark
//    }
//}